package com.kfm.am.thread;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class Client {

    public static void main(String[] args) throws IOException {
        System.out.println("客户端启动成功！");
        Socket socket = new Socket("localhost",8888);  // 与目标服务器（主机地址 + 端口号）进行连接
        OutputStream out = socket.getOutputStream();  // 获取连接的输出流，写东西到服务端、
        DataOutputStream dataOut = new DataOutputStream(out);
        Scanner sc = new Scanner(System.in);
        System.out.println("你想说什么？");
        String msg = sc.next();
        dataOut.writeUTF(msg);
        System.out.println("发送消息成功");
        out.close();
        socket.close();
    }
}
